11# -*- coding: utf-8 -*-
from selenium import webdriver
from Utils.logger import Log
# 接收logger实例
getLogger = Log("browser")
log = getLogger.get_log()
# 方式一 封装
def get_browser(browser_type):
    if browser_type == 'Firefox':
        driver = webdriver.Firefox()
    elif browser_type == 'Chrome':
        driver = webdriver.Chrome()
    elif browser_type == 'IE':
        driver = webdriver.Ie()
    else:
        driver = webdriver.Chrome()

    # driver.maximize_window()
    # driver.implicitly_wait(10)

    return driver

#方式二 利用反射封装
def getBrowser(browser_type):
    try:
        driver = getattr(webdriver, browser_type)()
        log.info(browser_type+"浏览器启动成功")
    except Exception as e:
        log.error("浏览器加载失败 "+str(e))
        driver = webdriver.Chrome()
        log.info("默认打开了Chrome浏览器")
    return driver